package com.pro.service.imple;

import com.pro.mapper.JsUserFeedbackMapper;
import com.pro.pojo.JsUserFeedback;
import com.pro.service.JsUserFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 李佳豪
 * @date 2022/1/13 19:09
 */
@Service
public class JsUserFeedbackServiceImple implements JsUserFeedbackService {
    @Autowired
    JsUserFeedbackMapper jsUserFeedbackMapper;
    /**
     * @author 李佳豪
     * @date 2022/1/13 16:19
     * 查询所有反馈信息
     * 返回JsUserFeedback对象集合
     */
    @Override
    public List<JsUserFeedback> getAllJsUserFeedback(JsUserFeedback param) {
        return jsUserFeedbackMapper.getAllJsUserFeedback(param);
    }
    /**
     * @author 李佳豪
     * @date 2022/1/14 14:08
     * 点击通过按钮修改反馈状态
     * 返回true或false
     */
    @Override
    public boolean updateFeedbackStatus(JsUserFeedback param) {
        return jsUserFeedbackMapper.updateFeedbackStatus(param);
    }
    /**
     * @author 李佳豪
     * @date 2022/1/14 15:28
     * 根据id删除反馈信息
     * 返回true或false
     */
    @Override
    public boolean DeleteFeedbackById(Integer feedbackId) {
        return jsUserFeedbackMapper.DeleteFeedbackById(feedbackId);
    }
    /**
     * @author 李佳豪
     * @date 2022/1/14 15:36
     * feedbackCount 计算个数
     * 返回map集合
     */
    @Override
    public Map<String,Object> feedbackCount() {
        Integer stayExamine = 0;
        Integer alreadyExamine = 0;
        List<JsUserFeedback> jsUserFeedbacks = jsUserFeedbackMapper.feedbackCount();
        for (JsUserFeedback jsUserFeedback:jsUserFeedbacks) {
            if (jsUserFeedback.getFeedbackStatus() == 3){
                stayExamine++;
            }else{
                alreadyExamine++;
            }
        }
        Map<String, Object> map = new HashMap<>();
        map.put("stayExamine",stayExamine);
        map.put("alreadyExamine",alreadyExamine);
        return map;
    }
    /**
     * @author 李佳豪
     * @date 2022/1/14 15:55
     * QueryByStatusFeedback 根据状态查询对应数据
     * 返回JsUserFeedback对象集合
     */
    @Override
    public List<JsUserFeedback> QueryByStatusFeedback(Integer stayExamine,Integer alreadyExamine) {
        return jsUserFeedbackMapper.QueryByStatusFeedback(stayExamine,alreadyExamine);
    }
}
